<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <script type="text/javascript" src="./script/rem.js"></script>
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="yes" name="apple-touch-fullscreen">
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="./css/font-awesome.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <script type="text/javascript" src="./script/aui-slide.js"></script>
    <script type="text/javascript" src="./script/jquery.min.js"></script>
    <script type="text/javascript" src="./script/doT.min.js"></script>
    <script type="text/javascript" src="./script/base.js"></script>
    <script type="text/javascript" src="./script/api.js"></script></head>
    <script type="text/javascript" src="./script/aui-tab.js" ></script>
    <script type="text/javascript" src="./script/jquery-3.2.0.js"></script>
</head>
<!-- <li onclick="changeSort('college')" id="college"><p>商学院</p></li> -->
<body>
    <style>
        frame{z-index: 1;}
    </style>
<!--     <header class="find-head fixed" id="head" style="padding-top:0.4rem;">
        <div class="head-l" tapmode onclick="closeWin()"><i class="fa fa-angle-left"></i></div>
        <ul id="sort">
            <li id="title"><p></p></li>
        </ul>
    </header> -->

<!--     <header class="head" style="padding-top:0.4rem;" id="head" >
        <div class="head-l" tapmode onclick="closeWin()"><i class="fa fa-angle-left"></i></div>
        <h3 id="title"></h3>
        <div class="head-r"></div>
    </header> -->
    <!-- <div class="head-d" style="padding-top:0.4rem;"></div> -->
<!-- <div class="fenxiang-bg" style="display:block;">
    <div class="fenxiang" style="bottom:0">
        <ul class="fenxiang-t">
           <li>< img src="image/foot-share-1.png"></li> 
           <li>< img src="image/foot-share-2.png"></li> 
           <li>< img src="image/foot-share-3.png"></li> 
        </ul>
        <div class="fenxiang-d">取消</div>
    </div>
</div> -->

<!-- 分享模块 -->
<!-- <div class="fenxiang-bg"> -->
<div class="fenxiang">
    <ul class="fenxiang-t">
        <li onclick="wxQiaoliaoShare();"><img src="image/foot-share-1.png"></li> 
        <li onclick="friendCircleQiaoliaoShare();"><img src="image/foot-share-2.png"></li> 
        <!-- <li><img src="image/foot-share-3.png"></li>  -->
    </ul>
    <div class="fenxiang-d">取消</div>
</div>
<!-- </div> -->


</body>
<script type="text/javascript" src="./script/api.js"></script>
<script type="text/javascript" src="./script/index.js"></script>
<script type="text/javascript">

    apiready = function(){

        // api.addEventListener({
        //     name:'viewappear'
        // }, function(ret, err){   
        //     api.setScreenOrientation({
        //         orientation: 'portrait_up'
        //     });
        // });

        // var offset = $api.offset($api.dom('#head'));

        api.addEventListener({
            name:'viewappear'
        }, function(ret, err){   
            api.setScreenOrientation({
                orientation: 'landscape_left'
            });
        });

        api.addEventListener({
            name:'keyback'
        }, function(ret, err){   
            api.confirm({
                title: '提示',
                msg: '是否退出?',
                buttons: ['确定', '取消']
            }, function(ret, err){
                if( ret ){
                    // alert( JSON.stringify( ret ) );
                    if (ret.buttonIndex == 1) {

                        api.setScreenOrientation({
                            orientation: 'portrait_up'
                        });

                        api.closeToWin({
                            name: 'root'
                        });
                    }
                }else{
                    // alert( JSON.stringify( err ) );
                }
            });
        });

        var token = $api.getStorage('token');
        var game_userid = $api.getStorage('game_userid');

        timer = setTimeout(function(){    

            api.showProgress({
                style: 'default',
                animationType: 'fade',
                title: '正在努力加载中...',
                modal: false
            });

        },888);

        api.openFrame({
            name: 'gameFrame',
            url: 'http://horse.yipinyizhuan.com:9526/?/m/?token=' + game_userid,
            rect: {
                x: 0,
                y: 0,
                w: 'auto',
                h: 'auto'
            },
            pageParam: {
                name: 'test'
            },
            bounces: false,
            bgColor: 'rgba(0,0,0,0)',
            vScrollBarEnabled: false,
            hScrollBarEnabled: false,
        });
    }
    
    // 调起分享
    function shareGame(content,url,imgUrl,title){

        // 下载
        api.download({
            url : imgUrl,
            savePath: 'fs://imgShare.jpg',
            report : false,
            cache : false,
            allowResume : false
        }, function(ret, err) {
            // alert(JSON.stringify(ret));
            if (ret.state == 1) {
                //下载成功
                // imgPath = ret.savePath;
                imgPath = 'fs://imgShare.jpg';

                var height = api.winHeight;
                var width = api.winWidth;
                api.openFrame({
                    name: 'game_share',
                    url: './game_share.html',
                    rect: {
                        x: 0,
                        y: height - 128,
                        w: width,
                        h: 128
                    },
                    pageParam: {
                        content: content,
                        url: url,
                        imgPath: imgPath,
                        title: title,
                    },
                    bounces: false,
                    bgColor: 'rgba(0,0,0,0)',
                    vScrollBarEnabled: false,
                    hScrollBarEnabled: false
                });

            }
        });

    }

    // 小游戏打开加载动画
    function openLoadingGame(){
        api.showProgress({
            style: 'default',
            animationType: 'fade',
            title: '正在努力加载中...',
            // text: '先喝杯茶...',
            modal: false
        });
        // var UILoading = api.require('UILoading');
        // UILoading.flower({
        //     center: {
        //         x: 160,
        //         y: 240
        //     },
        //     size: 30,
        //     fixed: true
        // }, function(ret) {
        //     // alert(JSON.stringify(ret));
        //     loadingId = ret.id;
        // });
    }

    // 小游戏关闭加载动画
    function closeLoadingGame(){

        api.hideProgress();

        // var UILoading = api.require('UILoading');
        // UILoading.closeFlower({
        //     id: 0
        // });
    }

    // 关闭最开始的加载动画
    function closeBeginningLoadingGame(){
        // alert(3333)
        // setTimeout(function(){    
            api.hideProgress();
        // },1);
    }

    // 小游戏竖屏
    function portraitUpGame(){
        api.setScreenOrientation({
            orientation: 'portrait_up'
        });
    }

    // 小游戏横屏
    function landscapeGame(){
        api.setScreenOrientation({
            orientation: 'landscape_left'
        });
    }


    function closeWin(){
        api.closeWin({
        });
    }
</script>
</html>